import logging
logger=logging.getLogger("simple_example")
print(logger.name)
logger.setLevel(logging.DEBUG)

ch=logging.StreamHandler()
ch.setLevel(logging.INFO)
fh=logging.FileHandler(filename="simple.log",mode="a",encoding="utf-8")
fh.setLevel(logging.WARNING)

formatter=logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch.setFormatter(formatter)
fh.setFormatter(formatter)

logger.addHandler(ch)
logger.addHandler(fh)

logger.debug('debug message')
logger.info('info message')
logger.warning('warn message')
logger.error('error message')
logger.critical("critical message")